#include "main.h"
#include <iostream>
using namespace std;

TreeNode* g_root = NULL;

void display(TreeNode* tree)
{
	if (tree == NULL) { return; }
	
	cout << tree->key << "->(";
	if (tree->leftChild) { cout << tree->leftChild->key; }
	else { cout << "nil"; }
	cout << ", ";
	if (tree->rightChild) { cout << tree->rightChild->key; }
	else { cout << "nil"; }
	cout << ", ";
	if (tree->color == TreeNode::Red) { cout << "R"; }
	else { cout << "B"; }
	cout << ")\n";	
	
	display(tree->leftChild);
	display(tree->rightChild);
	
}

int main(int argc, char **argv)
{
	int array[] = {1, 2, 3, 0, 5, 4};
	int len = sizeof(array) / sizeof(int);
	
//------------------------------------------------------
// Tree

	for (int i = 0; i < len; i++)
	{
		//bst_insert(array[i], array[i] + 1);
		rb_insert(array[i], array[i] + 1);
	}
	
//-------------------------------------------------------
	
	display(g_root);
	
	delete g_root;
	
	cin.get();
	return 0;
}
